
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <cstring>
#include <string.h>
#include <unistd.h>
#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)

char buf1[] = "abcdefghij";
char buf2[] = "ABCDEFGHIJ";

int main()
{
    int fd;
    if ((fd = creat("file.hole", FILE_MODE)) < 0)
        printf("creat error: %s", strerror(errno));

    if (write(fd, buf1, 10) != 10)
        printf("write buf1 error: %s", strerror(errno));

    if(lseek(fd, 0, SEEK_END)==-1)
        printf("lseek error: %s", strerror(errno));

    if (write(fd, buf2, 10) != 10)
        printf("write buf2 error: %s", strerror(errno));

        return 0;
}
